<%@ page import="java.util.List" %>
<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<!doctype html>
<html lang="en">
<head>
    <title>商品列表</title>
    <script>
        // 确认删除的函数
        function confirmDelete(delUrl) {
            return confirm("您确定要删除这个商品吗？");
        }
    </script>
</head>
<body>
<%
    if (session.getAttribute("tv_msg") != null)
    {
%>
<h2><%= session.getAttribute("tv_msg") %></h2>
<%
    }
%>
<h2>登录成功，欢迎 <%= session.getAttribute("username") %></h2>
<h3>当前分类： <%= session.getAttribute("kind") %></h3>
<%
    List<Object[]> tvList = (List<Object[]>) session.getAttribute("tvList");
%>
<table>
    <tr>
        <td>编号  </td>
        <td>名称  </td>
        <td>价格  </td>
        <td>图片  </td>
        <td>分辨率  </td>
        <td>种类  </td>
        <td>操作  </td>
    </tr>
    <%
        if(tvList!=null)
        {
        for (Object[] row : tvList)
        {
    %>
    <tr>
        <td> <%=row[0]%> </td>
        <td> <%=row[1]%> </td>
        <td> <%=row[2]%> </td>
        <td> <img src="${pageContext.request.contextPath}/imgs/<%=row[3]%>" width="80px" height="80px" alt=""></td>
        <td> <%=row[4]%> </td>
        <td> <%=row[5]%> </td>
        <td> <a href="delTV?tvId=<%=row[0]%>&kind=<%=row[5]%>" onclick="return confirmDelete('delTV?tvId=<%=row[0]%>&kind=<%=row[5]%>')">删除</a> </td>
        <td> <a href="set_picture.jsp?tvId=<%=row[0]%>&&kind=<%=row[5]%>" class="btn btn-primary">上传图片</a> </td>
    </tr>
    <%
        }}
    %>
    <form action="getAllTVs">
        <input type="hidden" name="kind" placeholder="分类名">
    </form>
</table>
<a href="add_tv.jsp">添加商品</a>
</body>
</html>